<?php

namespace app\client\controller;

use app\client\services\AlipayService;
use app\client\services\CustomerService;
use app\client\services\TiktokService;
use app\client\services\WeChatService;
use think\facade\Validate;

class Auth extends \app\BaseController
{
    protected $middleware=['CheckClientTokenMiddleware'=>['only'=>['logout','my']]];
    public function login(){
        $p=$this->request->post();
        $rule=[
            'platform'=>'require|in:dy,wx,zfb'
        ];
        $validate=Validate::rule($rule);
        if(!$validate->check($p)){
            api_return(500,'something wrong,try again later.');
        }
        switch ($p['platform']){
            case 'dy':
                TiktokService::login($p);
                break;
            case 'wx':
                WeChatService::WxLogin($p);
                break;
            case 'zfb':
                AlipayService::login($p);
                break;
            default:
                break;
        }
    }
    public function logout(){
        api_return(200);
    }
    public function my(){
        $customer_id=$this->request->adminUid;
        CustomerService::my($customer_id);
    }

}
